﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace PmSoft.ApplicationContext
{
    public interface IApplicationContextStateProvider
    {
        string Name { get; }
        Func<ApplicationContext, T?> Get<T>();
    }

    public static class ContextStateProviderCollectionExtensions
    {
        public static IServiceCollection ConfigureStateProvider<T>(this IServiceCollection services)
            where T : class, IApplicationContextStateProvider
        {
            services.AddScoped<IApplicationContextStateProvider, T>();
            services.AddScoped<T>();
            return services;
        }
    }
}
